<% layout('/layouts/default.html', {title: '数据管理', libs:
['validate','fileupload','ueditor','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-fire"></i> ${text(goodsType.isNewRecord ? '新增类型' : '编辑类型')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${goodsType}" action="${ctx}/goodsType/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4">${text('上级类型')}：</label>
							<div class="col-sm-8">
								<#form:treeselect id="parent" title="${text('上级类型')}"
									path="parent.id" labelPath="parent.name" 
									url="${ctx}/goodsType/treeData?excludeCode=${goodsType.id}"
									class="" allowClear="true" canSelectRoot="true" canSelectParent="true"/>
							</div>
						</div>
					</div>
					
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('排序号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="treeSort" maxlength="10" class="form-control required digits"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('类型名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="name" maxlength="200" class="form-control required "/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('类型编码')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:hidden path="isNewRecord"/>
								<#form:hidden path="goodsCode"/>
								<input type="hidden" name="oldType" value="${goodsType.type}"/>
								<#form:input path="viewCode" maxlength="64" readonly="${!goodsType.isNewRecord}" class="form-control required abc"/>
							</div>
						</div>
					</div>
				</div>
			
			<div class="row">
							
			<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('类型模块')}：<i
							class="fa icon-question hide"></i></label>
							
						<div class="col-sm-8"><#form:select path="type" 
							multiple="true"
							dictType="zt_goodsType_type" blankOption="true" class="form-control required"
							/></div>
					</div>
				</div>
			</div>
			
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control "/>
							</div>
						</div>
					</div>
				</div>
				
				
				<div class="row">
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2">${text('图片：<br/>尺寸700*1285')}</label>
						<div class="col-sm-10">
						
					
	
	<#form:fileupload id="upload2" returnPath="true" fileNameInputId="imgname"
							filePathInputId="img" bizKey="${goodsType.goodsCode}" bizType="user_upload2" uploadType="image"
							maxUploadNum="1"   readonly="false" isMini="false"/>
							<#form:input name="img" class="form-control"/>
							<#form:input name="imgname" class="form-control"/>

							</div>
					</div>
				</div>
			</div>
				
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('ztGoodsType:ztGoodsTypeData')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler : function(form) {
		js.ajaxSubmitForm($(form), function(data) {
			js.showMessage(data.message);
			if (data.result == Global.TRUE) {
				js.closeCurrentTabPage(function(contentWindow) {
					contentWindow.page();
				});
			}
		}, "json");
	}
});

// 选择父级菜单回调方法
function treeselectCallback(id, act, index, layero){
	if (id == 'parent' && (act == 'ok' || act == 'clear')){
		// 创建并初始化下一个节点信息，如：排序号、默认值
		$.get('${ctx}/goodsType/createNextNode?parentCode='
				+$('#parentCode').val(), function(data){
			$('#treeSort').val(data.treeSort);
		});
	}
}
</script>
